feat: maxLength - #755
Open
hejsztynx wants to merge 14 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds maxLength?: number support to EnrichedTextInput across Web/iOS/Android, enforcing the limit based on the editor’s plain text (ignoring ZWS) across typing, paste, and programmatic entry points, with new e2e coverage and demo screens.
Changes:
- Web: introduce a ProseMirror/Tiptap max-length extension and wire the new prop into the web editor setup.
- Native: expose
maxLengththrough the RN spec/manager and enforce it in iOS (utilities + insertion points) and Android (InputFilter + insertion helpers). - Tooling/docs/tests: document the prop, add example/test screens, and add Playwright + Maestro e2e coverage.
Reviewed changes
Copilot reviewed 24 out of 38 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/pmPlugins/MaxLengthPlugin.ts | New Tiptap/ProseMirror plugin that trims inserted ranges when doc exceeds maxLength. |
| src/web/EnrichedTextInput.tsx | Wires maxLength into the web editor via the new plugin. |
| src/types.ts | Adds maxLength?: number to EnrichedTextInputProps. |
| src/spec/EnrichedTextInputNativeComponent.ts | Exposes maxLength to native via codegen (default -1). |
| src/native/EnrichedTextInput.tsx | Passes maxLength prop through to the native component. |
| ios/utils/MaxLengthUtils.mm | Adds iOS utilities for plain-length counting and safe truncation (composed characters). |
| ios/utils/MaxLengthUtils.h | Declares the new iOS max-length helper API. |
| ios/styles/MentionStyle.mm | Makes mention insertion respect remaining capacity and clamps mention range when truncated. |
| ios/inputHtmlParser/InputHtmlParser.mm | Truncates parsed HTML processing results (text/styles/alignments) to capacity and truncates fallback raw insertion. |
| ios/EnrichedTextInputView.mm | Applies maxLength config updates; truncates defaultValue/setValue; enforces maxLength in typing path; clamps link/image insertions. |
| ios/enrichedInputTextView/EnrichedInputTextView.mm | Truncates pasted plain text fragments to remaining capacity. |
| ios/config/EnrichedConfig.mm | Stores and normalizes maxLength in config (<0 => unlimited). |
| ios/config/EnrichedConfig.h | Defines EnrichedMaxLengthUnlimited and adds config getter/setter. |
| docs/INPUT_API_REFERENCE.md | Documents the new maxLength prop behavior and platforms. |
| apps/example/src/screens/TestScreen.tsx | Adds UI controls to toggle maxLength in the native example app. |
| apps/example-web/src/testScreens/TestMaxLength.tsx | Adds a dedicated web test screen exercising maxLength across entry points. |
| apps/example-web/src/RouteSelector.tsx | Adds routing to the new /test-max-length web test screen. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/MaxLengthFilter.kt | Adds maxLength grapheme-safe truncation helpers and an InputFilter enforcing the limit. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt | Adds helper to replace/insert while reporting actual inserted length (post-filter). |
| android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt | Updates link/image/mention insertion to respect maxLength shortening/rejection. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt | Adds @ReactProp(maxLength) plumbing to the Android manager. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Installs maxLength filter and truncates pasted fragments to preserve post-caret content. |
| .playwright/tests/maxLength.spec.ts | Adds Playwright e2e tests covering typing/paste/selection replace/link/mention/image behaviors. |
| .maestro/scripts/setup-android-emulator.sh | Adjusts emulator port used by Maestro setup script. |
| .maestro/enrichedInput/flows/max_length.yaml | Adds Maestro flow validating native maxLength behavior (typing/paste/set value/link/mention). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
hejsztynx
marked this pull request as ready for review
August 10, 2026 11:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #732.
Provided the implementation of the
maxLengthprop to theEnrichedTextInputcomponent.EnrichedTextInput's content will be limited to the given number of characterssetValue,defaultValue, typing, pasting content or programmatically viaref.setImage(),ref.setImage(),ref.setLink()Test Plan
There's an available interface on mobile on the
TestScreenand under/test-max-lengthURL on web.Compatibility
Checklist